﻿var NewsManage = {
    Delete: function () {
        var ids = $("input[name='newsids']").getCheckBoxValue().toString();
        if (ids == null || ids == undefined || ids == "") {
            alertMsg.info('请选择要删除的新闻！');
            return false;
        }
        alertMsg.confirm('确定要删除勾选的新闻吗？', { okCall: function () {
            $.ajax({
                url: "Manage/News/Delete",
                data: { 'ids': ids },
                dataType: 'json',
                success: function (data) {
                    if (data.statusCode == DWZ.statusCode.ok) {
                        alertMsg.correct(data.message);
                        navTab.openTab(data.navTabId, data.forwardUrl, { title: data.title, fresh: true });
                    }
                }
            });
        }
        });
    },
    SaveNews: function (obj, callbackfn) {
        var title = $(obj).find("input[name='title']").val();
        if (title == null || title == undefined || title == "") {
            alertMsg.error("请填写新闻标题！");
            return false;
        }
        //        var url = $(obj).find("input[name='url']").val();
        //        if (url == null || url == undefined || url == "") {
        //            alertMsg.error("请填写链接地址！");
        //            return false;
        //        }
        if (confirm("确定要保存新闻吗？")) {
            return validateCallback(obj, callbackfn);
        }
        else {
            return false;
        }

    },
    SaveTitlePic: function (obj, callbackfn) {
        var title = $(obj).find("input[name='file1']").val();
        if (title == null || title == undefined || title == "") {
            alertMsg.error("请选择要上传的图片！");
            return false;
        }
        if (confirm("确定要提交上传吗？")) {
            return iframeCallback(obj, callbackfn);
        }
        else {
            return false;
        }
    },
    DeletePic: function () {
        if (confirm("确定要删除图片吗？")) {
            var defaultPath = $("#news_titlePic").attr("default");
            $("#news_titlePic").attr("src", defaultPath);
            $(".img_box").find("input[name='title_pic']").val(defaultPath);
        }
    },
    navTabAjaxDone: function (data) {
        if (data.statusCode == DWZ.statusCode.ok) {
            //            $.pdialog.closeCurrent();
            navTab.openTab(data.navTabId, data.forwardUrl, { title: data.title, fresh: true });
            setTimeout(function () {
                alertMsg.correct(data.message);
            }, 500);
        }
        else if (data.statusCode == DWZ.statusCode.error) {
            alertMsg.error(data.message);
        }
    },
    dialogUploadDone: function (data) {
        if (data.statusCode == DWZ.statusCode.ok) {
            $.pdialog.closeCurrent();
            $("#news_titlePic").attr("src", System_Path + "content/uploads/temp/" + data.Data);
            $(".img_box").find("input[name='title_pic']").val(data.Data);
        }
        else if (data.statusCode == DWZ.statusCode.error) {
            alertMsg.error(data.message);
        }
    }
}